﻿using CoreCms.Net.Bz.SetupModule;
using CoreCms.Net.Web.Admin.Authorization;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Yitter.IdGenerator;

namespace CoreCms.Net.Web.Admin
{
    /// <summary>
    /// 自定义的一些业务
    /// </summary>
    public class ConfigureService : IConfigureService
    {
        public void ConfigureServices(IServiceCollection services, IConfiguration configuration)
        {
            //添加数据库连接SqlSugar注入支持
            services.AddSqlSugarSetup();

            //Jwt
            services.
                    AddSilkyJwtBearerIdentity<AdminAuthorizationPermissionHandler>(defaultAutherication: true)
                    .AddHttpContextService();

            //健康检查
            //services.AddCoreCmsHealthyCheckService();

            // 雪花漂移算法
            // 创建 IdGeneratorOptions 对象，请在构造函数中输入 WorkerId：
            var options = new IdGeneratorOptions(1);
            // 保存参数（必须的操作，否则以上设置都不能生效）：
            YitIdHelper.SetIdGenerator(options);
        }
    }
}